﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyBlog.WebUI.Models;
namespace MyBlog.WebUI.Controllers
{

    [Authorize]
    public class BackStageController : Controller
    {
        //
        // GET: /Home/
        MyBlogEntities db = new MyBlogEntities();

        private int PageSize = 3;

        
     
       
        public ActionResult Index(int page=1)
        {
            IEnumerable<User> users = db.Users.OrderBy(p=>p.userId)
                .Skip((page-1)*PageSize)
                .Take(PageSize);

            int Total = db.Users.Count();
             int num=0;
             if (Total % PageSize == 0)
                 num = Total / PageSize;
             else
                 num = Total / PageSize + 1;

            ViewBag.pageNum = num;
            return View(users);
        }
 

     

    }
}
